package com.block.datapush.special.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.datapush.special.enums.SpecialApiTypeEnum;
import com.block.datapush.special.api.*;
import com.block.datapush.special.service.IApiPushService;

import java.util.HashMap;
import java.util.Map;

public class ApiPushFactory {

    private static Map<String, Class<? extends IApiPushService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(SpecialApiTypeEnum.COMMON.getValue(), CommonApiPushService.class);
        serviceMap.put(SpecialApiTypeEnum.BONAJINXI.getValue(), BoNaJinXiApiPushService.class);
        serviceMap.put(SpecialApiTypeEnum.ANHUIZEAO.getValue(), AnHuiZeAoApiPushService.class);
        serviceMap.put(SpecialApiTypeEnum.HAOHAN.getValue(), HaoHanApiService.class);

    }

    public static IApiPushService getService(String filterKey){
        if (serviceMap.containsKey(filterKey)){
            Class<? extends IApiPushService> aClass = serviceMap.get(filterKey);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }

}
